#include "../server/Rpc_server.hpp"

void Add(const Json::Value& req,Json::Value& rsp)
{
    LOG(INFO,"进入Add函数");
    int num1 = req["num1"].asInt();
    int num2 = req["num2"].asInt();
    rsp = num1 + num2;

    //LOG(INFO,"rsp: %d",rsp["result"].asInt());

}

int main()
{

    std::unique_ptr<ns_router::SDescribeFactory> desc_factory(new ns_router::SDescribeFactory());
    desc_factory->Setmethodname("Add");
    desc_factory->Setparas("num1",ns_router::Vtype::INTEGER);
    desc_factory->Setparas("num2",ns_router::Vtype::INTEGER);
    desc_factory->SetResult(ns_router::Vtype::INTEGER);
    desc_factory->SetCb(Add);
    
    ns_rpc_server::RpcServer server(Address("127.0.0.1",8080));
    server.RegisterMethod(desc_factory->Build());
    server.Start();
    return 0;
}